package com.egreen.system.controller;


import com.egreen.common.pojo.DTO.system.LogisticsInformationDTO;
import com.egreen.common.pojo.DTO.system.SendFeedbackDTO;
import com.egreen.system.dao.UserFeedbackDao;
import com.egreen.system.service.impl.CommodityExchangeRecordServiceImpl;
import com.egreen.common.Result;
import com.egreen.common.States;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author cloudJiang
 * @since 2022-07-16
 */
@RestController
@RequestMapping("/commodityExchangeRecord")
public class CommodityExchangeRecordController {
    @Autowired
    CommodityExchangeRecordServiceImpl commodityExchangeRecordService;

    @ApiOperation(value = "物流信息修改", notes = "通过updateLogisticsInformation对物流信息进行修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commodityId", value = "用户物流Id", required = true),
            @ApiImplicitParam(name = "logisticsInformation", value = "物流信息", required = true),
            @ApiImplicitParam(name = "logisticsInformationDTO", value = "以上属性被封装到这个DTO里")
    })
    @PostMapping("/logisticsInformation")
    Result logisticsInformation(@Validated @RequestBody LogisticsInformationDTO logisticsInformationDTO) {
        commodityExchangeRecordService.updateLogisticsInformation(logisticsInformationDTO.getCommodityId(), logisticsInformationDTO.getLogisticsInformation());
        return Result.OK(States.OK);
    }

    @ApiOperation(value = "用户反馈信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title", value = "反馈标题", required = true),
            @ApiImplicitParam(name = "content", value = "反馈信息", required = true),
            @ApiImplicitParam(name = "userId", value = "用户id", required = true),
            @ApiImplicitParam(name = "sendFeedbackDTO", value = "以上属性被封装到这个DTO里")
    })
    @PostMapping("/sendFeedback")
    Result sendFeedback(@Validated @RequestBody SendFeedbackDTO sendFeedbackDTO) {
        commodityExchangeRecordService.sendFeedback(sendFeedbackDTO);
        return Result.OK(States.OK);
    }
}

